home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Graphics / TVPaint / Rexx / math.rx < prev    next >
Encoding:
Text File  |  1995-11-07  |  1.3 KB  |  102 lines

  1. /*    param none */
  2.  
  3. /*  display a mathematical function in 3d */
  4.  
  5.     options results
  6.  
  7.     address 'rexx_TVPaint'
  8.  
  9.  
  10. /* reset */
  11.  
  12.     tv_UpdateUndo
  13.     tv_SetDrawMode    Color
  14.     tv_AliasOn
  15.     tv_StencilOff
  16.     tv_DensityOff
  17.     tv_CycleOff    
  18.     tv_AeroSpline 10 245
  19.     tv_AeroPower 10
  20.     tv_DensitySpline 255 50
  21.     tv_XMax
  22.     tv_YMax
  23.     tv_WrapX    0
  24.     tv_WrapY    0
  25.     tv_RangeV
  26.  
  27.     tv_Clear
  28.  
  29.     x=100
  30.     offx=20
  31.     offy=150
  32.  
  33.     dx=14
  34.     dy=7
  35.  
  36.     lw=20
  37.     lh=20
  38.  
  39. /* generating table with a function */
  40.  
  41.  
  42.     do j=1 to lh
  43.         do i=1 to lw
  44.  
  45.             a.i.j =((i-(lw%2))*(i-(lw%2))+(j-(lh%2))*(j-(lh%2)))-200     
  46.  
  47. /* try also with other functions */
  48.  
  49. /*            a.i.j =(i-(lw%2))-((i-(lw%2))*(i-(lw%2)))+(j-(lh%2))-((j-(lh%2))*(j-(lh%2)))*/
  50.  
  51. /*            a.i.j =(i-(lw%2))*(i-(lw%2))-(j-(lh%2))*(j-(lh%2))        */
  52.  
  53. /*            a.i.j =i*j%2    */
  54.  
  55.  
  56.         end
  57.     end
  58.  
  59. /* let's go drawing */
  60.  
  61.  
  62.     do j=2 to lh
  63.  
  64.         offy=offy+dy
  65.  
  66.         do i=lw to 2 by -1
  67.             z=i-1
  68.             zz=j-1
  69.             x=i*dx+offx+dx
  70.  
  71.             col=(a.i.j-a.i.zz)*4+(a.z.j-a.i.j)*4+128
  72.             if col>255 then col=255
  73.             if col<0 then col=0
  74.             tv_SetAPen col col col 255
  75.  
  76.             tv_AreaInit
  77.             tv_AreaMove x-dx-dx offy-a.z.zz-dy
  78.             tv_AreaMove x-dx offy-a.i.zz-dy
  79.             tv_AreaMove x offy-a.i.j
  80.             tv_AreaMove x-dx offy-a.z.j
  81.             tv_AreaDraw
  82.  
  83.         end
  84.         offx=offx+dx
  85.     end
  86.  
  87. /* colorizing the screen */
  88.  
  89.     tv_SetDrawMode    Colorize
  90.     tv_SetAPen 128 0 255 255
  91.     
  92.     tv_GetWidth
  93.     width=result
  94.  
  95.     tv_GetHeight
  96.     height=result
  97.  
  98.     tv_RectFill 0 0 width-1 height-1
  99.  
  100.     tv_SetDrawMode    Color
  101.  
  102.